<?php if(!defined("PATH_HD")){exit("No direct script access allowed");}define("TEMP_FILE_EXISTS",1);?><?php
class tag { function _arclist($attr, $content) { $cid = isset($attr['cid'])?$attr['cid']: (isset($_GET['cid'])?$_GET['cid']:null); $row = isset($attr['row'])?$attr['row']:10; $type = isset($attr['type'])?$attr['type']:null; $where =''; if($cid){ $where = "cid =$cid"; } switch($type){ case 'hot': $order = "click desc"; break; default: $order = "aid desc"; } $str=''; $str.='<?php $db = M("arc");'; $str.='$result= $db->where("'.$where.'")->field("aid,title,addtime,click,thumbimg")->limit('.$row.')->order("'.$order.'")->all();'; $str.='foreach($result as $field):
            $field["img"] = $field["thumbimg"];
            $field["url"]=get_url($field);
        ?>'; $str.=$content; $str.='<?php endforeach;?>'; return $str; } function _catlist($attr,$content){ $cid = isset($attr['cid'])?$attr['cid']:(isset($_GET['cid'])?$_GET['cid']:null); $where =''; if($cid){ $where="pid =$cid"; } $str=''; $str.='<?php $db = M("category");'; $str.='$result= $db->where("'.$where.'")->all();'; $str.='foreach($result as $field1):
            $field1["url"]=get_arcurl($field1);
        ?>'; $str.=$content; $str.='<?php endforeach;?>'; return $str; } } ?><?php
 function get_url($field){ return __CONTROL__.'&m=arc&aid='.$field['aid']; } function get_arcurl($field1){ return __CONTROL__.'&m=cat&cid='.$field1['cid']; } function format_time($time){ $now = time(); $today = strtotime(date('Y-m-d')); $yesterday = strtotime('-1 day',$today); $diff = $now - $time; $str = ''; switch ($time) { case $diff < 60: $str = $diff.'秒前'; break; case $diff < 3600: $str = floor($diff/60).'分钟前'; break; case $diff > $today: $str = floor($iff/3600).'小时前'; break; case $diff > $yesterday: $str = '昨天' . date ('H:i:m',$time); break; default: $str = date('Y-m-d',$time); } return $str; } ?>